package com.lxc.service;

import java.util.*;
import com.lxc.dao.MusicTable;
import com.lxc.common.Music;
import com.lxc.common.TwoWayTranslateBetweenObjectAndMap;
public class MusicDatabase{
    public void saveMusic(Music music){
		System.out.println("musicDatabase");
		System.out.println(music.toString());
		TwoWayTranslateBetweenObjectAndMap twoWay = new TwoWayTranslateBetweenObjectAndMap();
		HashMap<String,Object> hashMap =(HashMap<String,Object>) twoWay.objectToMap(music);
		MusicTable musicTable = new MusicTable();
		musicTable.addMusic(hashMap);
    }
	
    public Music getMusic(int id){
      Music music = new Music();
      MusicTable musicTable = new MusicTable();
      HashMap hashMap =(HashMap) musicTable.getMusic(id);
	  System.out.println("MusicDatabase.getMusic");
	  System.out.println(hashMap.get("id"));
	  System.out.println(hashMap.get("singer"));
	  System.out.println(hashMap.get("song_name"));
	  System.out.println(hashMap.get("image_address"));
	  System.out.println(hashMap.get("music_address"));
	  TwoWayTranslateBetweenObjectAndMap twoWay = new TwoWayTranslateBetweenObjectAndMap();
      twoWay.mapToObject(hashMap,music);
      return music;
    }
	
}